<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/include/head_common.html">
<title>菜单<#if menu.id??&&menu.id!=''>修改<#else>添加</#if></title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#name").focus();
				$("#inputForm")
						.validate(
								{
									submitHandler : function(form) {
										loading('正在提交，请稍等...');
										form.submit();
									},
									errorContainer : "#messageBox",
									errorPlacement : function(error, element) {
										$("#messageBox").text("输入有误，请先更正。");
										if (element.is(":checkbox")
												|| element.is(":radio")
												|| element.parent().is(
														".input-append")) {
											error.appendTo(element.parent()
													.parent());
										} else {
											error.insertAfter(element);
										}
									}
								});
				$("#iconButton").click(function(){
					top.$.jBox.open("iframe:/tag/iconselect?value="+$("#icon").val(), "选择图标", 700, $(top.document).height()-180, {
			            buttons:{"确定":"ok", "清除":"clear", "关闭":true}, submit:function(v, h, f){
			                if (v=="ok"){
			                	var icon = h.find("iframe")[0].contentWindow.$("#icon").val();
			                	icon = $.trim(icon).substr(5);
			                	$("#iconIcon").attr("class", "icon-"+icon);
				                $("#iconIconLabel").text(icon);
				                $("#icon").val(icon);
			                }else if (v=="clear"){
				                $("#iconIcon").attr("class", "icon- hide");
				                $("#iconIconLabel").text("无");
				                $("#icon").val("");
			                }
			            }, loaded:function(h){
			                $(".jbox-content", top.document).css("overflow-y","hidden");
			            }
			        });
				});
			});
	function goback(){
    	$.cookie('goback','goback',{path: '/',expires: 1});
    	history.go(-1);
    }
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="list">菜单列表</a></li>
		<li class="active"><a href="edit?id=${menu.id!''}">菜单<#if menu.id??&&menu.id!=''>修改<#else>添加</#if></a></li>
	</ul>
	<br />
	<form id="inputForm" action="edit" method="post"
		class="form-horizontal">
		<input name = "id" type="hidden" value="${menu.id!''}" />
		<div class="control-group">
			<label class="control-label">上级菜单:</label>
			<div class="controls">
				<select name="parentId"  style="width:250px">
					<option value='1'>请选择父菜单，必须选一个</option>
					<#list list as data> 
						<#if data.name??&&data.name!=''>
							<option value='${data.id}' <#if menu.id??&&data.id==menu.parentId>selected</#if> >${data.name}</option>
						</#if> 
					</#list>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<input name="name" type="text" maxlength="50"
					class="required input-xlarge" value="${menu.name!''}" /> <span
					class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">链接:</label>
			<div class="controls">
				<input name="href" type="text" maxlength="2000"
					class="input-xxlarge" value="${menu.href!''}" /> <span
					class="help-inline">点击菜单跳转的页面</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">目标:</label>
			<div class="controls">
				<input type="text" name="target" maxlength="10" class="input-small"
					value="${menu.target!''}" /> <span class="help-inline">链接地址打开的目标窗口，默认：mainFrame</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">图标:</label>
			<div class="controls">
				<i id="iconIcon" class="icon-icon"></i>&nbsp;<label id="iconIconLabel"><#if menu.icon??&&menu.icon!=''>${menu.icon}<#else>无</#if></label>&nbsp;
				<input id="icon" name="icon" type="hidden" value="${menu.icon!''}"/><a id="iconButton" href="javascript:" class="btn">选择</a>&nbsp;&nbsp;
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">排序:</label>
			<div class="controls">
				<input type="text" name="sort" value="${menu.sort!''}"
					maxlength="50" class="required digits input-small" /> <span
					class="help-inline">排列顺序，升序。</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">可见:</label>
			<div class="controls">
				<#if menu.isShow??&&menu.isShow!=''>
					<label><input name="isShow" type="radio" value="1"<#if menu.isShow=='1'>checked="checked"</#if> />显示</label> 
					<label><input name="isShow" type="radio" value="0"<#if menu.isShow=='0'>checked="checked"</#if> />隐藏</label> <span class="help-inline">该菜单或操作是否显示到系统菜单中</span>
				<#else>
					<label><input name="isShow" type="radio" value="1" checked="checked" />显示</label> 
					<label><input name="isShow" type="radio" value="0"/>隐藏</label> <span class="help-inline">该菜单或操作是否显示到系统菜单中</span>
				</#if>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">权限标识:</label>
			<div class="controls">
				<input type="text" name="permission" value="${menu.permission!''}"
					maxlength="100" class="input-xxlarge" /> <span class="help-inline">控制器中定义的权限标识，如：@RequiresPermissions("权限标识")</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<textarea name="remarks" class="input-xxlarge">${menu.remarks!''}</textarea>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit"
				value="保 存" />&nbsp;&nbsp; <input id="btnCancel" class="btn"
				type="button" value="返 回" onclick="goback()" />
		</div>
	</form>
</body>
</html>